﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SiChuan.FormsApp.AppCode.Helpers;
using SiChuan.FormsApp.AppCode.Extensions;
using System.Text.RegularExpressions;
using SiChuan.FormsApp.AppCode.Models;

namespace SiChuan.FormsApp {
    public partial class ToolForm : Form {

        static string _url = "http://10.92.0.95:8090/ReportService.svc?wsdl";

        public ToolForm() {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e) {
            NlogHelper.Info("程序已运行");
        }

        private void button1_Click(object sender, EventArgs e) {
            if (textBox1.Text.IsNullOrWhiteSpace()) {
                return;
            }
            string req_str = "";
            if (textBox1.Text.LastIndexOf("<?xml version=\"1.0\" encoding=\"utf-8\"?>") < 0) {
                req_str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + textBox1.Text;
            } else {
                req_str = textBox1.Text;
            }

            textBox2.Text = req_str.StringToBase64();

        }

        private void button2_Click(object sender, EventArgs e) {
            string res_str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<接口>\r\n<令牌>5bceef508f71476190a314adc3dd101e</令牌>\r\n<数据类型>3</数据类型>\r\n<操作类型>4</操作类型>\r\n<操作单位>榆次区人民医院</操作单位>\r\n<操作用户> yysx_ycqrmyy2 </操作用户>\r\n<操作状态>1</操作状态>\r\n<状态描述>病例【5d68ce61c9b84baeb4cb4cd0eaabd007】上报成功</状态描述>\r\n</接口>\r\n";
            var ss = res_str.XmlToObjectForString<接口>();
        }

        private async void button3_Click(object sender, EventArgs e) {
            if (textBox1.Text.IsNullOrWhiteSpace()) {
                MessageBox.Show("请输入请求参数");
                return;
            }
            var txt = await textBox1.Text.HisAddCaseAsync(Guid.NewGuid().ToString("N").ToLower());
            var ss = txt.XmlToObjectForString<接口>();
            if (ss.操作状态 == "1") {

            } else {

            }
            textBox2.Text = txt;
        }
    }
}
